﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace dpdw.Structure.CompositePattern
{
    public class Menu : MenuComponent
    {
        string name;
        string description;

        ArrayList menuComponents = new ArrayList();

        public Menu(string name, string description)
        {
            this.name = name;
            this.description = description;
        }

        public override void Add(MenuComponent menuComponent)
        {
            menuComponents.Add(menuComponent);
        }

        public override void Remove(MenuComponent menuComponent)
        {
            menuComponents.Remove(menuComponent);
        }

        public override MenuComponent GetChild(int i)
        {
            return menuComponents[i] as MenuComponent;
        }

        public override string GetName()
        {
            return this.name;
        }

        public override string GetDescription()
        {
            return this.description;
        }

        public override void Print()
        {
            System.Diagnostics.Trace.WriteLine("===========Menu============");

            for (int i = 0; i < menuComponents.Count; i++)
            {
                System.Diagnostics.Trace.WriteLine(
                    (menuComponents[i] as MenuComponent).GetName()
                    + "-->"
                    + (menuComponents[i] as MenuComponent).GetDescription()
                    + "-->"
                    + (menuComponents[i] as MenuComponent).GetPrice());
            }
        }
    }
}
